package com.ts.mapper.achievement;
import com.ts.entity.TeacherHonors;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherHonorsMapper {

    /**
     * 存入一条荣誉获奖数据并且主键返回
     * @param teacherHonors
     */
    @Insert("insert into `tianshi-college-teacher-system-test`.ts_teacher_honors " +
            "(honors_name, honors_level, honors_type, awardee, ranks, " +
            "award_unit, award_time, certificate_no, is_teacher, is_student, " +
            "is_first_unit, achievement_source, subject_classification, college_id, " +
            "remarks, certificate_path, create_by, create_time, " +
            "update_by, update_time) values (" +
            "#{honorsName}, #{honorsLevel}, #{honorsType}, #{awardee}, #{ranks}, " +
            "#{awardUnit}, #{awardTime}, #{certificateNo}, #{isTeacher}, #{isStudent}, " +
            "#{isFirstUnit}, #{achievementSource}, #{subjectClassification}, #{collegeId}, " +
            "#{remarks}, #{certificatePath}, #{createBy}, #{createTime}, " +
            "#{updateBy}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "Id", keyColumn = "id")
    void save(TeacherHonors teacherHonors);
    /**
     * 更新荣誉获奖数据
     * @param teacherHonors 荣誉获奖实体
     */
    @Update("UPDATE `tianshi-college-teacher-system-test`.ts_teacher_honors SET " +
            "honors_name = #{honorsName}, " +
            "honors_level = #{honorsLevel}, " +
            "honors_type = #{honorsType}, " +
            "awardee = #{awardee}, " +
            "ranks = #{ranks}, " +
            "award_unit = #{awardUnit}, " +
            "award_time = #{awardTime}, " +
            "certificate_no = #{certificateNo}, " +
            "is_teacher = #{isTeacher}, " +
            "is_student = #{isStudent}, " +
            "is_first_unit = #{isFirstUnit}, " +
            "achievement_source = #{achievementSource}, " +
            "subject_classification = #{subjectClassification}, " +
            "college_id = #{collegeId}, " +
            "remarks = #{remarks}, " +
            "certificate_path = #{certificatePath}, " +
            "update_by = #{updateBy}, " +
            "update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(TeacherHonors teacherHonors);

    /**
     * 根据ID删除荣誉获奖数据
     * @param id 荣誉获奖ID
     */
    @Delete("DELETE FROM `tianshi-college-teacher-system-test`.ts_teacher_honors WHERE id = #{id}")
    void delete(Long id);

    /**
     * 根据ID查询荣誉获奖数据
     * @param id 荣誉获奖ID
     * @return 荣誉获奖实体
     */
    @Select("SELECT * FROM `tianshi-college-teacher-system-test`.ts_teacher_honors WHERE id = #{id}")
    TeacherHonors getById(Long id);

    /**
     * 查询所有荣誉获奖数据
     * @return 荣誉获奖列表
     */
    @Select("SELECT * FROM `tianshi-college-teacher-system-test`.ts_teacher_honors")
    List<TeacherHonors> listAll();


}
